package ns.gflex.domain

/**
 * Functions
 * @since Dec 23, 2010
 * @author wangchu
 */
class Param {
	String code
	String name
	String value
	ParamType type
	String validExp //属性值类型正则表达式校验
	String validDescribe //校验说明
	User lastUser
	Date lastUpdated

	static mapping = {
		type lazy:false,fetch:'join'
		lastUser lazy:false,fetch:'join'
	}

	static constraints = {
		code unique:true
		lastUser nullable:true
	}

	String toString(){
		"$code - $value"
	}
	static init ={
		def type =  new ParamType(code:'system',name:'系统参数',seq:1)
		def admin = User.findByAccount('admin')
		type.save()
		new Param(code:'AllowAnonymousLogin',name:'允许匿名登录',value:'false',type:type,validExp:'^(true|false)$',validDescribe:'true或者false',lastUser:admin).save()
		new Param(code:'SpareMintues',name:'空闲多少分钟后自动退出',value:'20',type:type,validExp:'^\\d+$',validDescribe:'整数',lastUser:admin).save()
		new Param(code:'HoldHeartBeat',name:'保持登录状态',value:'true',type:type,validExp:'^(true|false)$',validDescribe:'true或者false',lastUser:admin).save()
	}
}
